from flask import current_app, request
from user_agents import parse


def logger_handle():
    user_agent_str = request.headers.get("User-Agent")
    user_agent = parse(user_agent_str)
    browser = user_agent.browser.family
    os = user_agent.os.family
    current_app.logger.info(
        '请求地址：{} 请求方法：{} 请求路径：{} 浏览器：{} 系统：{}'.format(
            request.remote_addr,
            request.method,
            request.path,
            browser,
            os
        ))
